<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>发布信息</title>
    <link rel="stylesheet" th:href="@{'/webjars/layui/2.3.0/css/layui.css'}">
    <link rel="shortcut icon" th:href="@{'/img/favicon.ico'}">
    <link rel="stylesheet" th:href="@{'/webjars/font-awesome/4.7.0/css/font-awesome.css'}">
    <script language="JavaScript" th:src="@{'/webjars/jquery/3.3.1/dist/jquery.min.js'}"></script>
    <script language="JavaScript" th:src="@{'/js/dateformat.js'}" charset="utf-8"></script>
    <script language="JavaScript" th:src="@{'/webjars/ckeditor/4.7.3/full/ckeditor.js'}" charset="utf-8"></script>

    <script language="JavaScript">
        $(function () {
            layui.use(["laydate", "form", "layedit"], function () {
                var $form = layui.form;
                $form.on("submit(infoAdd)", function (data) {
                    data.field.infoContent = CKEDITOR.instances.editor.getData();
                    $.ajax({
                        url: data.form.action,
                        type: data.form.method,
                        data: data.field,
                        dataType: "json",
                        success: function (res) {
                            console.log(res);
                            if (res.code === 200) {
                                window.location.href = "/stu/info/to/info/get";
                            }
                        }
                    });
                    return false;
                });
            });
        });
    </script>

</head>
<body>
<ul th:insert="~{fragment/header :: top}"></ul>
<br>
<div class="layui-container layui-fluid layui-row">
    <form th:action="@{'/info/add'}" th:method="post" class="layui-form">
        <div class="layui-form-item layui-col-lg-offset1 layui-col-lg10 layui-form-pane">
            <label class="layui-form-label">发布标题</label>
            <div class="layui-input-block">
                <input type="text" name="infoTitle" placeholder="请输入标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-col-lg-offset1 layui-col-lg10 layui-form-pane">
            <label class="layui-form-label">公开类别</label>
            <div class="layui-input-block">
                <input type="radio" name="infoType" placeholder="请输入标题" class="layui-input" th:title="主动公开"
                       th:value="主动公开" checked>
                <!--<input type="radio" name="infoType" placeholder="请输入标题" class="layui-input" th:title="公开" th:value="公开">-->
            </div>
        </div>
        <div class="layui-form-item layui-col-lg-offset1 layui-col-lg10 layui-form-pane">
            <textarea id="editor" name="infoContent" class="layui-textarea" width="100%"></textarea>
        </div>
        <div class="layui-form-item layui-col-lg-offset3 layui-col-lg4">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="infoAdd">发布</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</div>
<div th:insert="~{fragment/header :: footer}"></div>
</body>
<script language="JavaScript">
    // 指定textarea的id或name
    CKEDITOR.replace('editor',
        {
            height: 300,
            language: 'zh-cn',
            filebrowserImageUploadUrl: '/stu/info/uploadImg', //注意此处由于浏览器内核不同，路径有些许不同。
            image_previewText: ' 预览内容，此处设为空',
            resize_enabled: false,
            toolbar:
                [
                    //加粗     斜体，     下划线      穿过线      下标字        上标字
                    ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
                    // 数字列表          实体列表            减小缩进    增大缩进
                    ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'],
                    //左对 齐             居中对齐          右对齐          两端对齐
                    ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
                    //超链接  取消超链接 锚点
                    ['Link', 'Unlink', 'Anchor'],
                    //图片       表格       水平线           表情符号   特殊字符        分页符
                    ['Image', 'Table', 'HorizontalRule', "Smiley", 'SpecialChar', 'PageBreak'],
                    // 样式      格式    字体    字体大小
                    ['Styles', 'Format', 'Font', 'FontSize'],
                    //文本颜色     背景颜色
                    ['TextColor', 'BGColor'],
                    //打印        拼写检查     即时拼写检查 撤销   重做
                    ["Print", "SpellChecker", "Scayt", "Undo", "Redo"],
                ],
            smiley_path: "/stu/plugins/smiley/images/",
            smiley_images: [
                '1.png', 'angel_smile.gif', 'angry_smile.gif',
                'broken_heart.gif', 'confused_smile.gif', 'cry_smile.gif',
                'devil_smile.gif', 'embaressed_smile.gif', 'embarrassed_smile.gif',
                'envelope.gif', 'heart.gif', 'kiss.gif', 'lightbulb.gif', 'omg_smile.gif',
                'regular_smile.gif', 'sad_smile.gif', 'shades_smile.gif', 'teeth_smile.gif',
                'thumbs_down.gif', 'thumbs_up.gif', 'tongue_smile.gif', 'tounge_smile.gif',
                'whatchutalkingabout_smile.gif', 'wink_smile.gif'
            ],
        }
    );
</script>
<script language="JavaScript" th:src="@{'/webjars/layui/2.3.0/layui.all.js'}" charset="utf-8"></script>
</html>